package ArrayListDemo1;

import java.util.ArrayList;

public class ArrayListdemo1
{
    //目标：掌握Arraylist集合的基本使用。
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();

        //添加数据
        list.add("java1");
        list.add("java2");
        list.add("java3");
        list.add("杨幂");
        System.out.println(list);
        //查找数据
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        System.out.println(list.get(2));
        System.out.println(list.get(3));

        System.out.println("=======================");

        //遍历数据
        for(int i = 0;i <list.size();i++)
        {
            String s = list.get(i);
            System.out.println(s);
        }

        System.out.println("=======================");
        //删除数据
        list.remove(0);
        System.out.println(list);
        list.remove("java2");
        System.out.println(list);
        //修改数据
        list.set(0,"java4");
        System.out.println(list);
    }
}
